cmake: add LLVM coverage support - #8376
Conversation
If FLB_COVERAGE is on, FLB_COVERAGE_TYPE can be configured for the coverage type, which is one of: - gcov (default) - llvm Signed-off-by: Seigo Tanimura <seigo.tanimura@gmail.com>
This allows llvm-profdata(1) to collect the test execution profiles. Signed-off-by: Seigo Tanimura <seigo.tanimura@gmail.com>
|
Hi, I know little about this but how the coverage stuff helps to get this build on BSD? |
My ultimate goal is to address the build breakage on FreeBSD due to the use of The wrapper function of Although LLVM can emit the gcov coverage data somehow, that is merely a compatibility feature. It is better to support the LLVM-native coverage support to minimize the build prerequisites, as well as to avoid any problems that may happen in the compatibility feature only. The coverage part has been separated from the main fix because they change the different modules in Fluent Bit; the former changes the build system (hence tagged by The main |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
@altimeter-130ft would you mind fixing the conflicts in this PR so it can be reviewed and moved forward? |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR adds the coverage support to the platform with the LLVM/clang only, without GCC.
Background
This change is essential for FreeBSD as the Fluent Bit development platform. The
masterbranch as of f8bd0ce does not build on FreeBSD 14.0-RELEASE because of thestrerror_r(3)signature dependency on glibc. I am addressing this issue in parallel, in which the code coverage is required to prove the fix.New CMake Build Option(s)
FLB_COVERAGE_TYPEgcov: (default) gcov; native for GCC, compatible with LLVM/clang.llvm: LLVM; native for LLVM/clang.FLB_COVERAGEis required.Change(s) to
CMAKE_C_FLAGS-fprofile-instr-generate -fcoverage-mapping.These are the standard CFLAGS options to enable the code coverage profile instrumentation on LLVM/clang.
Change(s) to Test Execution Environment
LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR}/(testname).profraw.runtime_shelltest can execute at most one test binary.Out of Scope
llvm-profdata.llvm-cov.Tested Environment
Testing
Before we can approve your change; please submit the following in a comment:
N/AExample configuration file for the changeThis change does not add any new features to the Fluent Bit binary.
logs-fluent-bit-topic-llvm-coverage.zip: The archive of the log files and sample LLVM coverage report.logs-fluent-bit-topic-llvm-coverage/fluent-bit-cmake-topic-llvm-coverage-debian_x86_64_12_2.log: Thecmakelog.env CC=clang-14 CXX=clang++-14 CPP=clang-cpp-14 LD=ld.lld RANLIB=llvm-ranlib-14 cmake -DFLB_COVERAGE=true -DFLB_COVERAGE_TYPE=llvm -DFLB_DEV=true -DFLB_VALGRIND=true -DFLB_TESTS_RUNTIME=true ..fluent-bit-make-topic-llvm-coverage-debian_x86_64_12_2.log: Themakelog.env CC=clang-14 CXX=clang++-14 CPP=clang-cpp-14 LD=ld.lld RANLIB=llvm-ranlib-14 makefluent-bit-ctest-topic-llvm-coverage-debian_x86_64_12_2.log: Thectestlog.ctestflb-rt-out_td: The test environment problem, I cannot make the valid test configuration.SIGTERM.in_syslog_uds_dgram_plaintext_expect.sh,in_syslog_uds_stream_plaintext_expect.sh: These are known to stall for more than 5 minutes, found during the test rehearsal. The results afterSIGTERMare both successful.fluent-bit-find-profraw-topic-llvm-coverage-debian_x86_64_12_2.log: The LLVM profile files found afterctest.find tests -type f -name '*.profraw'fluent-bit-llvm-profdata-cov-topic-llvm-coverage-debian_x86_64_12_2.log: The LLVM profile data collection and coverage report generation.llvm-cov-test-topic-llvm-coverage-debian_x86_64_12_2.tar.xz: The LLVM coverage report in HTML.N/AAttached Valgrind output that shows no leaks or memory corruption was foundThis change does not touch any C sources.
This change does not touch the packaging.
Documentation
Doc PR: installation: sources: Add FLB_COVERAGE and FLB_COVERAGE_TYPE. fluent-bit-docs#1289
Backporting
There is a fix depending on this PR. (pal: platform abstraction layer and strerror_r(3) wrapper #8390)
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.